/**
 * 
 */
package com.dwa.presentation.spring.web;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.dwa.domain.INews;
import com.dwa.domain.service.INewsAppService;

/**
 * @author Vedamoorthi Vairam
 *
 */
@Controller
@RequestMapping("/home.html")
public class HomeController {
private static final Logger logger = Logger.getLogger(HomeController.class);

	@Autowired
	private INewsAppService newsAppService;
	
	@RequestMapping(method = RequestMethod.GET)
	public ModelAndView form(Model modelll) throws Exception {		
		List<INews> newsList = newsAppService.getNewsByNewsDate(new Date());
		
		System.out.println("SIZEEEEEEEEEE  "+ newsList.size());
		Map map = new HashMap();
		map.put("news", newsList);
		ModelAndView mav = new ModelAndView("main", map);
		return mav;
	}

}
